home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / e / kyz_obj.lha / test / rexxtest.e < prev   
Text File  |  1998-09-27  |  2KB  |  69 lines

  1. OPT OSVERSION=37,PREPROCESS
  2.  
  3. MODULE 'tools/easygui', 'plugins/ticker', '*rexxstate'
  4.  
  5. DEF rxs=NIL:PTR TO rexxstate, tick=NIL:PTR TO ticker,
  6.     or, os, ot, oc, tg, cg
  7.  
  8.  
  9. PROC main() HANDLE
  10.   NEW rxs.new()
  11.   NEW tick
  12.   easygui_fallbackA('ARexx state', gui(), [EG_WTYPE, WTYPE_NOSIZE, 0])
  13. EXCEPT DO
  14.   END tick
  15.   END rxs
  16. ENDPROC
  17.  
  18. #define RUNNING_NAME IF or := rxs.running() THEN \
  19.   '_Shutdown ARexx' ELSE '_Start ARexx'
  20. #define SUSPEND_NAME IF os := rxs.suspended() THEN \
  21.   'Res_ume ARexx programs' ELSE 'S_uspend ARexx programs'
  22.  
  23. PROC gui() IS [EQROWS,
  24.   [BUTTON, {running}, RUNNING_NAME,        0, "s"],
  25.   [BUTTON, {suspend}, SUSPEND_NAME,        0, "u"],
  26.   [BUTTON, {halt}, '_Halt Arexx programs', 0, "h"],
  27.   [PLUGIN, {update}, tick],
  28.  
  29.   [BAR],
  30.  
  31. tg := [CHECK, {trace}, '_Trace mode',    ot := rxs.tracing(),      0, 0, "t"],
  32. cg := [CHECK, {cons},  'Trace _console', oc := rxs.console_open(), 0, 0, "c"]
  33. ]
  34.  
  35.  
  36. -> action procedures
  37.  
  38. PROC update(gh, x)
  39.   -> called 10 times a second (when the window is activated) by the ticker
  40.   -> this will update the GUI if someone else changes the state of ARexx,
  41.   -> with another command or such.
  42.   -> the old states (or, os, ot & oc) are updated when calling gui()
  43.   IF (rxs.running() <> or) OR (rxs.suspended() <> os) OR
  44.   (rxs.tracing() <> ot) OR (rxs.console_open() <> oc) THEN
  45.     changegui(gh, gui())
  46. ENDPROC
  47.  
  48. PROC running(gh)
  49.   IF rxs.running() THEN rxs.shutdown() ELSE rxs.start()
  50.   update(gh, 0) -> will need to redraw GUI if button name changed
  51. ENDPROC
  52.  
  53. PROC suspend(gh)
  54.   IF rxs.suspended() THEN rxs.resume() ELSE rxs.suspend()
  55.   update(gh, 0) -> will need to redraw GUI if button name changed
  56. ENDPROC
  57.  
  58. PROC halt() IS rxs.halt()
  59.  
  60. PROC trace(gh)
  61.   IF rxs.tracing() THEN rxs.trace_off() ELSE rxs.trace_on()
  62.   setcheck(gh, tg, ot := rxs.tracing())
  63. ENDPROC
  64.  
  65. PROC cons(gh)
  66.   IF rxs.console_open() THEN rxs.close_console() ELSE rxs.open_console()
  67.   setcheck(gh, tg, oc := rxs.console_open())
  68. ENDPROC
  69.